package org.langcom.live;

import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.langcom.logic.ILogic;

public class AbstarctLiveStage<T> implements ILiveStage<T> {

	protected T item;
	protected ILiveStage previousStage;
	protected ILogic logic;
	protected String description;
	protected String tooltip;
	protected Set<ILiveStage> parents = new HashSet<ILiveStage>();
	protected Set<ILiveStage> children = new HashSet<ILiveStage>();

	public ILiveStage becameFrom() {
		return previousStage;
	}

	public Set<ILiveStage> getChildren() {
		return children;
	}

	public String getDescription() {
		return description;
	}

	public ILogic getLogic() {
		return logic;
	}

	public Set<ILiveStage> getParents() {
		return parents;
	}

	public String getTooltip() {
		return tooltip;
	}

	public void setLogic(ILogic logic) {
		this.logic = logic;
	}

	public ILiveStage testItem(T item, ILiveStage previousStage) {
		this.item = item;
		this.previousStage = previousStage;
		return null;
	}

	public void addChild(ILiveStage<T> liveStage) {
		children.add(liveStage);
		liveStage.addParent(this);
	}

	public void addParent(ILiveStage<T> liveStage) {
		parents.add(liveStage);
	}

	public int hashCode() {
		return new HashCodeBuilder(-1984554517, 1305058959)
			.append(this.description).append(
				this.previousStage).append(this.logic).append(this.tooltip).toHashCode();
	}

}
